package com.gzist.elderlyserviceplatform.controller.client;

import com.gzist.elderlyserviceplatform.common.Result;
import com.gzist.elderlyserviceplatform.entity.po.Comment;
import com.gzist.elderlyserviceplatform.entity.vo.ClientCommentVo;
import com.gzist.elderlyserviceplatform.service.CommentService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 评论信息表
 */
@RestController
@Tag(name = "评论信息管理")
@RequestMapping("/api/client/comment")
@RequiredArgsConstructor
public class CommentControllerC {

    private final CommentService commentService;

    //根据活动id查看评论信息，在根据评论主键获取二级评论
    @GetMapping("/list/{id}")
    @Operation(summary = "根据活动id查看评论信息，在根据评论主键获取二级评论")
    public Result<List<ClientCommentVo>> list(@PathVariable String id){
        return Result.success(commentService.list(id),"查询成功");
    }

    //用户发表评论
    @PostMapping("/save")
    @Operation(summary = "用户发表评论")
    public Result save(@RequestBody Comment comment){
        commentService.addComment(comment);
        return Result.success("评论成功");
    }

    //回复评论
    @PostMapping("/reply")
    @Operation(summary = "回复评论")
    public Result reply(@RequestBody Comment comment){
        commentService.addReplyComment(comment);
        return Result.success("回复成功");
    }
}